package org.youchan.aco.ui;

import java.awt.BorderLayout;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

public class MembersViewPanel extends JPanel {
	private static final long serialVersionUID = -1761874240428547964L;

	private MembersListTable mTable;
	private MemberInformationPanel mMemberInfo;
	
	public MembersViewPanel() {
		super();
		init();
	}
	
	private void init() {
		this.setLayout(new BorderLayout());
		
		mTable = new MembersListTable();
		JScrollPane scrollPane = new JScrollPane(mTable);
		this.add(scrollPane, BorderLayout.CENTER);
		
		mMemberInfo = new MemberInformationPanel();
		this.add(mMemberInfo, BorderLayout.NORTH);

		mTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
			public void valueChanged(ListSelectionEvent e) {
				mMemberInfo.setMember(mTable.getSelectedMember());
			}
		});
	}
}
